
<#assign _type = "${RequestParameters['type']}" />
<@t.plat_body pageid="infos_${_type}">

<script type="text/javascript" src="${base}/js/plugins/datatables/datatables.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/datatables/datatables_basic.js"></script>
<script type="text/javascript" src="${base}/js/excellentexport.js"></script>
<script type="text/javascript" src="${base}/js/plugins/selects/select2.min.js"></script>
<style>
    .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
        padding: 4px;
    }
    .form-control{
        height: 28px;
    }
    .datatable-header, .datatable-footer{
        padding-top: 0px;
    }
</style>
<div class="panel panel-flat">
    <div class="panel-heading">
        <#if _type=='1'>
            <h5 class="panel-title">学生管理</h5>
        <#else>
            <h5 class="panel-title">教师管理</h5>
        </#if>

        <div class="heading-elements">
        </div>
    </div>

    <div class="panel-body" >
        <table class="listTable table table-striped table-bordered dataTable" id="userTable">
        </table>
    </div>
</div>
<script>
    function delRec(id) {
        createConfirm('您确定要删除该数据',function() {
            post('pl/info/del_infos?id='+id,function (result) {
                if(result.code==0){
                    table.ajax.reload();
                }else{
                    alertError(result.message);
                }
            });
        });
    }
    var result_data=[]
    function export_infos() {
        var index = layer.msg('正在处理，请稍后...', {
            icon: 16
            ,time:1000000000
            ,shade: [0.3,'#000000']
        });
        result_data=[];
        get('pl/info/list_infos?type=${_type}&limit=10000',function (result) {
            if(result.data.length==0){
                layer.close(index);
                alertError('没有数据可导出');
                return
            }
            <#if _type=='1'>
                result_data.push(['学号','姓名','班级','身份证号','联系电话','电子邮箱','专业','创建时间']);
                result.data.map(function (value,i) {
                    result_data.push([value.sno,value.name,value.classname,value.idno,value.mobile,value.email,value.zy,new Date(value.createdate).format('yyyy-MM-dd hh:mm:ss')]);
                });
                setTimeout(function () {
                    $('.layui-layer-content').html('导出成功，点击下载文件<a href="#" onclick="return ExcellentExport.convert({anchor: this, filename: \'学生信息\', format: \'xlsx\'}, [{name: \'学生列表\',from: {array: result_data}}])" style="color: #4fc3f7;font-style: normal" id="saveys-number">下载</a>，或者取消下载<a href="#" onclick="layer_close_all()">取消</a>');
                },1000)
            <#else>
                result_data.push(['警号','姓名','部门','身份','身份证号','联系电话','电子邮箱','专业','创建时间']);
                result.data.map(function (value,i) {
                    result_data.push([value.sno,value.name,value.dept,value.pid,value.idno,value.mobile,value.email,value.zy,new Date(value.createdate).format('yyyy-MM-dd hh:mm:ss')]);
                });
                setTimeout(function () {
                    $('.layui-layer-content').html('导出成功，点击下载文件<a href="#" onclick="return ExcellentExport.convert({anchor: this, filename: \'教师信息\', format: \'xlsx\'}, [{name: \'教师列表\',from: {array: result_data}}])" style="color: #4fc3f7;font-style: normal" id="saveys-number">下载</a>，或者取消下载<a href="#" onclick="layer_close_all()">取消</a>');
                },1000)
            </#if>


        },10000000000)
    }

    var table;
    $(function () {
        table=simpleTable('userTable', [
    <#if _type=='1'>
        {
            sWidth:80,
            dataIndex: 'sno',
            title: "学号"
        },
    <#else>
        {
            sWidth:80,
            dataIndex: 'sno',
            title: "警号"
        },
    </#if>

                {
                sWidth:80,
                dataIndex: 'name',
                title: "姓名"
            },
                <#if _type=='1'>
                    {
                        sWidth:80,
                        dataIndex: 'classname',
                        title: "班级"
                    },
                <#else>
                    {
                        sWidth:120,
                        dataIndex: 'dept',
                        title: "部门"
                    },
                    {
                        sWidth:120,
                        dataIndex: 'pid',
                        title: "身份"
                    },
                </#if>
            {
                sWidth:120,
                dataIndex: 'idno',
                title: "身份证号"
            },{
                sWidth:120,
                dataIndex: 'mobile',
                title: "联系电话"
            },{
                sWidth:120,
                dataIndex: 'email',
                title: "电子邮箱"
            },{
                sWidth:120,
                dataIndex: 'zy',
                title: "专业"
            },

            {
                sWidth:140,
                dataIndex: 'createdate',
                title: "创建时间",
                type:'datetime'
            },
            {
                sWidth:200,
                title: "操作",
                dataIndex: 'id',
                sClass:'text-center',
                render: function (data, type, full) {
                    var html = '<div>';
                    html+='<a style="margin-left: 2px" href="javascript:void(0)" onclick="dialogBox(\'${base}/plat/info/infos_edit?type=${_type}&id='+data+'\', \'编辑\', 450, 350);" class="btn btn-success btn-xs btn-outline">编辑</a>';
                    html+='<a href="javascript:void(0)" style="margin-left: 2px" onclick="delRec(\''+data+'\')" class="btn btn-danger btn-xs btn-outline">删除</a>';
                    html+='<a style="margin-left: 2px" href="javascript:void(0)" onclick="dialogBox(\'${base}/changePwd?code='+data+'\', \'修改密码\', 600, 300);" class="btn bg-purple-400 btn-xs btn-outline">修改密码</a>';
                    html+='</div>';
                    return html;
                }
            }
        ], {
            bAutoWidth:false,
            searching: true,
            bLengthChange: false,
            bSort: false,
            url: '${base}/pl/info/list_infos?type=${_type}&limit=10000',
            pageLength: 10
        });

        $("div.datatable-toolbar").html('<form class="pull-right navbar-left" id="searchForm">' +
                '<a href="${base}/plat/info/infos_im?type=${_type}" style="margin-left: 2px" class="btn btn-primary">导入</a>' +
                '<a href="#" onclick="export_infos()" style="margin-left: 12px" class="btn btn-success">导出</a>' +
                '</form>');
        $('.dataTables_length select,.datatable-toolbar select').select2({
            minimumResultsForSearch: "-1"
        });
    });






</script>
</@t.plat_body>
